home *** CD-ROM | disk | FTP | other *** search
/ Family Forum 261 / SOMC Family Forum 261.iso / Xtras / Behavior Library.cst / 00034_Script_UI Radio Group Item < prev    next >
Text File  |  1997-11-17  |  3KB  |  95 lines

  1. -- Setting  Radio   Group Item
  2.  
  3.  
  4. -- behavior library version 1.1
  5. -- control, drag this onto a system radio button to add it to a group
  6. -- check if it works for push button, check box, radio button
  7.  
  8. -- will receive setRadioValue, getRadioValue, radio_button_selected, groupname 
  9. -- which_radio_button_selected returns the text of the selected item of the group
  10.  
  11. property  GroupName, GroupSetting
  12. property  selectedButton, default
  13.  
  14. on mouseUp me
  15.   setGroupValue me
  16. end
  17.  
  18. on beginSprite me
  19.   if default = TRUE then
  20.     SendAllSprites #clearGroup, groupname
  21.     set selectedButton = the spritenum of me
  22.     setgroupValue me
  23.   else
  24.     SendAllSprites #clearGroup, groupname
  25.   end if
  26. end
  27.  
  28. on getRadioValue me, GName
  29.   if GName = the GroupName of me then
  30.     dontPassEvent
  31.     return the text of member (the member of sprite (the selectedButton of me))
  32.   end if
  33. end
  34.  
  35. on setRadioValue me, GName, selected_sprite_num
  36.   set MNum  = the member of sprite (the spritenum of me)
  37.   
  38.   if GName = the GroupName of me then   
  39.     if the spritenum of me <> selected_sprite_num then
  40.       radioHilite me, FALSE
  41.     else
  42.       radiohilite me, TRUE
  43.     end if
  44.     set the selectedButton of me to selected_sprite_num 
  45.   end if
  46. end
  47.  
  48.  
  49. on setGroupValue me  
  50.   SendAllSprites #SetRadioValue, the GroupName of me, the spritenum of me
  51.   radioHilite me, TRUE
  52. end
  53.  
  54. on clearGroup me, gname
  55.   if  GName = the GroupName of me then
  56.     if default = FALSE then
  57.       radioHilite me, FALSE
  58.     else
  59.       radioHilite me, TRUE
  60.     end if  
  61.   end if
  62. end
  63.  
  64.  
  65. ---
  66.  
  67. on getPropertyDescriptionList
  68.   
  69.   return [  #GroupName: [ #default: #group1, #format:#symbol, #comment:"Group Name"],   #default  : [ #default: 0, #format:#boolean, #comment:"Initially Selected?"]   ]
  70.   
  71. end
  72.  
  73. on getBehaviorDescription
  74.   return "Includes the current sprite in a radio button group. Attach to toggle buttons controlled by the UI Toggle Button behavior, or radio buttons created with the Radio Button tool on the Tools palette. The GetRadioValue message returns the text of the selected button. "&RETURN&"PARAMETERS:"&RETURN&"ò Group Name - Enter the name of the group to which this radio button belongs.  Only one member of the group can be selected at at time. Do not use spaces."&RETURN&"òáInitially Selected - Turn this option on to make this radio button selected when the sprite first appears.  If more than one radio button has Initially Selected on, the highest numbered sprite is selected. "&RETURN&"MESSAGES:" & RETURN & "ò GetRadioValue group_name - Returns the text of the named radio group's selected button." & RETURN & "ò SetRadioValue group_name, sprite_number - Sets the named radio button group's setting to be the sprite."& RETURN & "ò SetGroupValue - Sets the sprite to the group setting."
  75. end
  76.  
  77.  
  78.  
  79. on getAssocMembers --added, fmk
  80.   set myPropList = [  ]
  81.   
  82.   return myPropList
  83. end getAssocMembers
  84.  
  85.  
  86.  
  87. on RadioHilite me, val
  88.   -- assumes if the sprite is not of type button, that it is a toggle button.  If it's neither no adverse effect.
  89.   if ( the type of member ( the memberNum of sprite ( the spriteNum of me)) = #button)  then
  90.     set the hilite of member (the member of sprite (the spritenum of me)) to val
  91.   else
  92.     sendSprite (the spritenum of me, #setToggleValue, val )
  93.   end if
  94. end
  95.